const {getTopHttp} = require("../../models/douban-Top250")
Page({
  data: {
    movies:""
  },
  onLoad: async function(options) {
    var res = await getTopHttp()
    // console.log(res);
    let movies = [];
    res.data.result.forEach(res=>{
      let {pic,title,raiting} = res;
      let arr = star(raiting)
      movies.push({
        coverImgUrl:pic,
        name:title,
        raiting,
        arr
      })
    }) 
    this.setData({
      movies,
    })
    console.log(this.data.movies);

    // 处理星星
    function star(num){
      var arr =[]
      for(;num>2;num -= 2){
          arr.push(2)
      }
      num = Number(num.toFixed(1));
      arr.push(num);
      return arr
    }
  },
})